<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>竞品品类管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
   
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/zTreeStyle/demo.css" type="text/css">
    <link rel="stylesheet" href="__STATIC__/zTreeStyle/zTreeStyle.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
         #alertmod_table_list_2 {
            top: 900px !important;
        }
        .alerts{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgba(0,0,0,0.5);}
        .alerts .alerts_content{background:#fff;position: fixed;top: 50%;left: 50%; width: 700px;min-height: 500px;margin: -220px 0 0 -350px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
        .wait{ display:none;background:#f4f4f5;position: fixed;top: 50%;left: 50%; width: 700px;min-height: 250px;margin: -220px 0 0 -350px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
        .alerts .alerts_content h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 20px;padding-left: 1%;width: 99%;margin-bottom:30px;background: #d0e0e0}
        .alerts .alerts_content .alerts_form{
            width:100%;
        }
        .alert_addNewZone_tree{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgba(0,0,0,0.5);}
        .alert_addNewZone_tree .alert_addNewZone_content_tree{background:#fff;position: fixed;top: 50%;left: 50%; width: 500px;height: 300px;margin: -150px 0 0 -250px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
        .alert_addNewZone_tree .alert_addNewZone_content_tree h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 20px;padding-left: 1%;width: 99%;margin-bottom:30px;background: #d0e0e0}
        .alert_addNewZone .alert_addNewZone_content .alert_addNewZone_form{
            width:100%;
        }
        .alert_addNewZone_tree .alert_addNewZone_content_tree .alert_addNewZone_form_tree{
            height: 280px;
            overflow: scroll;
        }
        .alerts .alerts_content .alerts_form form{width: 100%;}
        .alerts .alerts_content .alerts_form form div{margin-bottom:30px;width: 100%;text-align: center;}
        .alerts .alerts_content .alerts_form form div label{display:inline-block;width: 130px;text-align: right;}
        .alerts .alerts_content .alerts_form form div:nth-of-type(1) input{margin-right: 28px;}
        .mtp{margin-top:3px;}
        .no-padding{padding: 0;}
        #gopage{color:blue;cursor: pointer;}
        #firstpage{cursor: pointer;}


        .alert_addNewZone_tree{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgb(255,255,255,0.7);z-index: 200}
        .alert_addNewZone_tree .alert_addNewZone_content_tree{background:#fff;position: fixed;top: 50%;left: 50%; width: 500px;height: 350px;margin: -150px 0 0 -250px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
        .wait,.waits{background:#f4f4f5;position: fixed;top: 50%;left: 50%; width: 500px;height: 300px;margin: -150px 0 0 -250px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
        .alert_addNewZone_tree .alert_addNewZone_content_tree h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 20px;padding-left: 1%;width: 99%;margin-bottom:10px;background: #d0e0e0}
    </style>
</head>

<body class="white-bg" style="color:#333;padding:3px;">
    <div class="page-heade">
       <h2 class="title_color text-center">
       	 	{if condition="$cfid eq 0"}
			添加竞品品类
			{else/}
			编辑竞品品类
			{/if}
       </h2>
    </div>
      
        <input type="hidden" value="{$cfid}" id="cfid"/>
        <div class="col-md-12 no-padding">
				<table class="table table-bordered bud_hei" style="width: 100%;">
					
					<tr style="font-size:14px;">
						<td style="width: 20%;">竞品品类编号<span style="color: red">*</span>:</td>
						<td style="width:40%;"><input type="text" id="category_no" {if condition="$data.category_no neq ''"} readonly value="{$data.category_no}" {/if} class="form-control" /></td>
						<td style="width:40%;color: red">
							(温馨提示，如不填写系统将自动分配)
						</td>
						
					</tr>
					<tr style="font-size:14px;">
						<td style="width: 20%;">竞品品类名称<span style="color: red">*</span>:</td>
						<td colspan="2"><input type="text" id="category_name" value="{$data.category_name}" class="form-control" /></td>
						
					</tr>
					
					<tr style="font-size:14px;">
						<td style="width: 20%;">备注:</td>
						<td colspan="2">
							<textarea id="remark" class="form-control" style="height:100px;resize: none;">{$data.remark}</textarea>
						</td>
						
					</tr>
					<tr class='font-bold text-center'>
						<td colspan="6">
							<button id="submits" class="btn btn-success">确定</button>
							<button id="back" class="btn btn-warning">返回列表</button>
						</td>
						
					</tr>
				</table>
			

				
			</div>
        

	<div class="alert_addNewZone_tree">
	        <div class="wait">
   				<div class="ibox ">
                    <div class="ibox-title">
                        <h5>正在处理，请稍后.....</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="spiner-example">
                            <div class="sk-spinner sk-spinner-chasing-dots">
                                <div class="sk-dot1"></div>
                                <div class="sk-dot2"></div>
                            </div>
                        </div>
                    </div>
                </div>

	        </div>
  		 </div>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="__STATIC__/layout/js/content.js?v=1.0.0"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
     <!-- layerDate plugin javascript -->
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
    <!-- ztree -->
    <script type="text/javascript" src="__STATIC__/zTreeStyle/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="__STATIC__/zTreeStyle/jquery.ztree.excheck.js"></script>
    <!--统计代码，可删除-->
	<script type="text/javascript">
	//产品名正则
 	var regex=/^[a-zA-Z0-9_\-()（）\u4e00-\u9fa5]{1,30}$/;
 	//产品编号
	var regex_no=/^[a-zA-Z0-9_\-]{1,20}$/;
	
		$("#submits").click(function(){
		
		var msg="";
		if($("#category_name").val()==""){
			msg="竞品品类名称不能为空";
		}else if(!regex.test($("#category_name").val())){
			msg="竞品品类名称为为字母，数字，中文，()，_，- 组成且长度不超过30";
		
		}else if($("#category_no").val()!=""){
			if(!regex_no.test($("#category_no").val())){
				msg="竞品品类编号为为字母，数字，_，- 组成且长度不超过20";
			}
		}
		if(msg==""){
			$(".alert_addNewZone_tree").show();
			//成功
			$.post("{:url('Competitor/add_category')}",
			{
				cfid:$("#cfid").val(),
				category_no:$("#category_no").val(),
				category_name:$("#category_name").val(),
				remark:$("#remark").val()
			},function(re){
				//alert(re);
				if(re!=""){
					var data=JSON.parse(re);
					if(data["state"]==1){
						swal({
						title: "完成",
						text:  data["msg"],
						type: "success"
						},function(){
							
								location.href='{:url("Competitor/category_manage")}';
							
						});
					}else{
						swal({
						title: "错误",
						text:  data["msg"],
						type: "warning"
						},function(){
							$(".alert_addNewZone_tree").hide();

						});
						
					}
				}

			})
		}else{
			swal({
					title: "错误",
					text:  msg,
					type: "warning"
				});
		}

	})
		
	$("#back").click(function(){
		
			location.href='{:url("Competitor/category_manage")}';
		
	})
	</script>

   	
</body>

</html>
